<template>
	<view class="content" :style="{background: `url(${imgPath}storage/home/home_bg.png)`}">
		<view class="box">
			<scroll-view class="temple" scroll-y @scrolltolower="getList">
				<view class="item" v-for="item in list" @click="goTempleDetail(item.temple_id)">
					<view class="left">
						<view class="top">
							{{item.name}}
						</view>
						<view class="bottom">
							<u-icon name="map" size="15"></u-icon>
							<text>{{item.address}}</text>
						</view>
					</view>
					<view class="right">
						<u--image :showLoading="true" :src="imgPath + 'storage/home/go.png'" width="40rpx" height="40rpx"></u--image>
					</view>
				</view>
			</scroll-view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				imgPath: this.$store.state.user.baseURL,
				list: [],
				paging: {
					page: 1,
					limit: 10,
				},
				total: null,
			}
		},
		onLoad() {
			this.getList()
		},
		onPullDownRefresh() {
			this.search()
			setTimeout(function() {
				uni.stopPullDownRefresh();
			}, 1000);
		},
		methods: {
			getList(){
				if(this.total == this.list.length) return
				this.$api.templelist(this.paging).then(res => {
					this.list = [...this.list, ...res.data.list]
					this.paging.page++
					this.total = res.data.total
				})
			},
			refresh(){
				this.total = null
				this.paging.page = 1
				this.list = []
			},
			goTempleDetail(id) {
				uni.navigateTo({
					url: '/pages/templelist/templedetail?id=' + id
				})
			},
		}
	}
</script>

<style scoped lang="scss">
	.content {
		min-height: 100vh;
		z-index: -1;
	}
	.box {
		padding: 0 30rpx;
		padding-top: 20rpx;
	}
	.temple{
		height: calc(100vh - 40rpx);
		// background: #fff;
	}
	.item{
		display: flex;
		justify-content: space-between;
		height: 148rpx;
		background: #FEF1DC;
		border-radius: 20rpx;
		padding: 0 30rpx;
		box-sizing: border-box;
		margin-bottom: 16rpx;
		.left{
			.top{
				padding-top: 36rpx;
				font-family: PingFangSC, PingFang SC;
				font-weight: 600;
				font-size: 30rpx;
				color: #111111;
				line-height: 42rpx;
				text-align: left;
				font-style: normal;
			}
			.bottom{
				padding-top: 10rpx;
				display: flex;
				text{
					padding-left: 5rpx;
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					font-size: 22rpx;
					color: #AAAAAA;
					line-height: 32rpx;
					text-align: left;
					font-style: normal;
				}
			}
		}
		.right{
			display: flex;
			justify-content: center;
			align-items: center;
		}
	}
</style>